home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Performance Co-Pilot 1.3
/
SGI Performance Co-Pilot 1.3.iso
/
dist
/
pcp.idb
/
usr
/
pcp
/
bin
/
pmnsadd.z
/
pmnsadd
Wrap
Text File
|
1997-04-03
|
2KB
|
91 lines
#!/bin/sh
# $Id: pmnsadd,v 2.1 1997/03/26 03:07:50 kenmcd Exp $
#
# Add a subtree of new names into the namespace in the current directory
exitsts=1
tmp=/var/tmp/$$
prog=`basename $0`
trap "rm -f $tmp.*; exit \$exitsts" 0 1 2 3 15
_usage()
{
echo "Usage: pmnsadd [-d] [-n namespace] file"
}
namespace=${PMNS_DEFAULT-/var/pcp/pmns/root}
dupok=""
umask 22 # anything else is pretty silly
while getopts dn:\? c
do
case $c
in
d) dupok="-d"
;;
n) namespace=$OPTARG
;;
\?) _usage
exitsts=0
exit
;;
esac
done
shift `expr $OPTIND - 1`
if [ $# -ne 1 ]
then
_usage
exit
fi
if [ ! -f $namespace ]
then
echo "$prog: cannot find PMNS file \"$root\""
exit
fi
if [ ! -w $namespace ]
then
echo "$prog: cannot open PMNS file \"$root\" for writing"
exit
fi
if [ ! -f $1 ]
then
echo "$prog: cannot find input file \"$1\""
exit
fi
# Find PMNS pathname for base of new subtree (subroot), construct upper
# levels of PMNS as required and hand-off to pmnsmerge
#
subroot=`nawk <$1 'NF >= 2 && $2 == "\{" { print $1 ; exit }'`
echo 'root {' >$tmp.tmp
path=""
for name in `echo "$subroot" | tr '.' ' '`
do
[ ! -z "$path" ] && echo "$path {" >>$tmp.tmp
echo " $name" >>$tmp.tmp
echo "}" >>$tmp.tmp
if [ -z "$path" ]
then
path="$name"
else
path="$path.$name"
fi
done
cat $1 >>$tmp.tmp
/usr/pcp/bin/pmnsmerge $dupok $namespace $tmp.tmp $tmp.root
exitsts=$?
if [ $exitsts = 0 ]
then
cp $tmp.root $namespace
cp $tmp.root.bin $namespace.bin
else
echo "$prog: No changes have been made to the PMNS file \"$namespace\""
fi